//
// NeL - bindings
// Copyright (C) 2010 Naush
//
//This program is free software: you can redistribute it and/or modify
//it under the terms of the GNU Affero General Public License as
//published by the Free Software Foundation, either version 3 of the
//License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU Affero General Public License for more details.
//
//You should have received a copy of the GNU Affero General Public License
//along with this program.  If not, see <http://www.gnu.org/licenses/>.

package org.ryzom.nel.misc;

public class CIFile {
  private long swigCPtr;
  protected boolean swigCMemOwn;

  public CIFile(long cPtr, boolean cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = cPtr;
  }

  public static long getCPtr(CIFile obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if (swigCPtr != 0) {
      if (swigCMemOwn) {
        swigCMemOwn = false;
        nelmiscJNI.delete_CIFile(swigCPtr);
      }
      swigCPtr = 0;
    }
  }

  public CIFile() {
    this(nelmiscJNI.new_CIFile__SWIG_0(), true);
  }

  public CIFile(String path, boolean text) {
    this(nelmiscJNI.new_CIFile__SWIG_1(path, text), true);
  }

  public CIFile(String path) {
    this(nelmiscJNI.new_CIFile__SWIG_2(path), true);
  }

  public boolean open(String path, boolean text) {
    return nelmiscJNI.CIFile_open__SWIG_0(swigCPtr, this, path, text);
  }

  public boolean open(String path) {
    return nelmiscJNI.CIFile_open__SWIG_1(swigCPtr, this, path);
  }

  public void setCacheFileOnOpen(boolean newState) {
    nelmiscJNI.CIFile_setCacheFileOnOpen(swigCPtr, this, newState);
  }

  public void allowBNPCacheFileOnOpen(boolean newState) {
    nelmiscJNI.CIFile_allowBNPCacheFileOnOpen(swigCPtr, this, newState);
  }

  public void setAsyncLoading(boolean newState) {
    nelmiscJNI.CIFile_setAsyncLoading(swigCPtr, this, newState);
  }

  public void close() {
    nelmiscJNI.CIFile_close(swigCPtr, this);
  }

  public void flush() {
    nelmiscJNI.CIFile_flush(swigCPtr, this);
  }

  public boolean seek(int offset, IStream.TSeekOrigin origin) {
    return nelmiscJNI.CIFile_seek(swigCPtr, this, offset, origin.swigValue());
  }

  public int getPos() {
    return nelmiscJNI.CIFile_getPos(swigCPtr, this);
  }

  public String getStreamName() {
    return nelmiscJNI.CIFile_getStreamName(swigCPtr, this);
  }

  public void getline(String buffer, long bufferSize) {
    nelmiscJNI.CIFile_getline(swigCPtr, this, buffer, bufferSize);
  }

  public long getFileSize() {
    return nelmiscJNI.CIFile_getFileSize(swigCPtr, this);
  }

  public boolean eof() {
    return nelmiscJNI.CIFile_eof(swigCPtr, this);
  }

  public void serialBuffer(SWIGTYPE_p_unsigned_char buf, long len) {
    nelmiscJNI.CIFile_serialBuffer(swigCPtr, this, SWIGTYPE_p_unsigned_char.getCPtr(buf), len);
  }

  public static long getNumFileOpen() {
    return nelmiscJNI.CIFile_getNumFileOpen();
  }

  public static long getNumFileRead() {
    return nelmiscJNI.CIFile_getNumFileRead();
  }

  public static long getReadFromFile() {
    return nelmiscJNI.CIFile_getReadFromFile();
  }

  public static long getReadingFromFile() {
    return nelmiscJNI.CIFile_getReadingFromFile();
  }

  public static void dump(Vector_String result) {
    nelmiscJNI.CIFile_dump(Vector_String.getCPtr(result), result);
  }

  public static void clearDump() {
    nelmiscJNI.CIFile_clearDump();
  }

}
